//
//  AXMySqrzVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/19.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXMySqrzVC.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "Header.h"
#import "UITableView+SDAutoTableViewCellHeight.h"
#import "AXMySqrzTableViewCell.h"
#import "UIViewController+HBD.h"
#import "AXMyZyxnrVC.h"
#import "AXMyXxnyzjVC.h"
#import "AXMyNyjyztVC.h"
#import "AXMyNzjyztVC.h"

@interface AXMySqrzVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic ,strong) UITableView *tableView;
/** 假数据 */
@property (nonatomic, strong) NSArray<NSString *> *titles;




@end

@implementation AXMySqrzVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    [self setupNavigationItems];
    [self initData];
    [self creatView];
    [self setlayout];
    /** 导航条白色 */
    self.hbd_barTintColor = [UIColor whiteColor];
    self.hbd_barShadowHidden = YES;
    

}

- (void)creatView {
    
    self.tableView = [[UITableView alloc]init];
    /** 去掉cell线 */
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[AXMySqrzTableViewCell class] forCellReuseIdentifier:[AXMySqrzTableViewCell reuseID]];
    [self.view addSubview:self.tableView];
    
    
    
}

- (void)initData {
    
    self.titles = @[@"职业新农人",@"新型农业专家",@"新型农业经营主体",@"新型农资经营主体",@"专业服务型企业"];
    
}

- (void)setlayout {
    
    self.tableView.sd_layout
    .leftSpaceToView(self.view, 0)
    .topSpaceToView(self.view, NAVIGATION_HEIGHT)
    .widthIs(Wi)
    .heightIs(TableViewHeight);
    
    
}

- (void)setupNavigationItems {
    
    /** 导航条左边的按钮 */
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 30, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    /** 搜索 */
    UILabel *titleLabel = [[UILabel alloc]init];
    titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
    titleLabel.text = @"新农人申请";
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = FONT_EIGHTEEN;
    titleLabel.textColor = [UIColor colorWithHex:0x29b566];
    self.navigationItem.titleView = titleLabel;
    
    
}

#pragma mark - Action

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - tableViewDelegate & tableViewDatasorce



//几个分区
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 5;
}

/** cell的高度 */

/** cell 自适应第二步 */
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return 44;
    
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    AXMySqrzTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[AXMySqrzTableViewCell reuseID] forIndexPath:indexPath];
    /** 小箭头 */
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    cell.titleLabel.text = self.titles[indexPath.row];
    
    
    return cell;
    
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
  //
    if (indexPath.row == 0) {
        
        AXMyZyxnrVC *vc = [[AXMyZyxnrVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
        
    }
    
    //新型农业专家
    
    if (indexPath.row == 1) {
        
         AXMyXxnyzjVC *vc = [[ AXMyXxnyzjVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    
    if (indexPath.row == 2) {
        
        AXMyNyjyztVC *vc = [[AXMyNyjyztVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    
    if (indexPath.row == 3) {
        
        AXMyNzjyztVC *vc = [[ AXMyNzjyztVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}



@end

